import { createRouter, createWebHistory } from 'vue-router'
// import NProgress from '@/config/nprogress.js'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      component: () => import('@/views/index/index.vue'),
      redirect: '/login',
      children: [
        {
          path: '/login',
          name: 'login',
          component: () => import('@/views/login/index.vue'),
        },
        {
          path: '/register',
          name: 'register',
          component: () => import('@/views/register/index.vue'),
        },
      ]

    },
    {
      path: '/home',
      name: 'home',
      component: () => import('@/views/home/index.vue'),
      redirect: '/home/index',
      children: [
        {
          path: 'index',
          name: 'home-index',
          component: () => import('@/views/main/index.vue'),
        },
        {
          path: 'stroll',
          name: 'home-stroll',
          component: () => import('@/views/stroll/index.vue'),
        },
        {
          path: 'work',
          name: 'home-work',
          component: () => import('@/views/work/index.vue'),
        },
        {
          path: 'manual',
          name: 'home-manual',
          component: () => import('@/views/manual/index.vue'),
        },
        {
          path: 'mine',
          name: 'home-mine',
          component: () => import('@/views/mine/index.vue'),
        },
        {
          path:'plant',
          name:'home-plant',
          component:()=>import('@/views/plant/index.vue')
        },
        {
          path:'post',
          name:'home-post',
          component:()=>import('@/views/post/index.vue')
        },
      ],
    },
    {
      path:'/manual/detail/:id',
      props:true,
      name:'manual-detail',
      component:()=>import('@/views/manual-detail/index.vue')
    },
    {
      path:'/post/detail/:id',
      props:true,
      name:'post-detail',
      component:()=>import('@/views/post-detail/index.vue')
    },
    {
      path:'/plant/detail/:id',
      props:true,
      name:'plant-detail',
      component:()=>import('@/views/plant-detail/index.vue')
    },
    {
      path:'/center',
      name:'center',
      component:()=>import('@/views/center/index.vue')
    },
    {
      path:'/my/collect',
      name:'my-collect',
      component:()=>import('@/views/my-collect/index.vue')
    },
    {
      path:'/my/plant',
      name:'my-plant',
      component:()=>import('@/views/my-plant/index.vue')
    },
    {
      path:'/password',
      name:'password',
      component:()=>import('@/views/password/index.vue')
    },
  ],
})

router.beforeEach((to, from, next) => {
  // NProgress.start()
  next()
})

router.afterEach(() => {
  // NProgress.done()
})

export default router
